#ifndef __Ogre7zCommon_H__
#define __Ogre7zCommon_H__
#pragma once

// Include stuff
#include "Ogre7zPrerequisites.h"
#include <7z.h>

namespace Ogre
{
	/**
	 * @brief Utility class for 7zip
	 */
	class SevenZipUtil
	{
	public:
		/**
		 * @brief Initialise all internal 7zip library objects
		 */
		static void initialiseLibrary();

		/**
		 * @brief Implementation of 7zip memmory alloc function
		 */
		static void* allocImpl( void* p, size_t size );

		/**
		 * @brief Implementation of 7zip memmory free function
		 */
		static void freeImpl( void* p, void* address );

		/**
		 * @brief Retrieves alloc structure for 7zip
		 */
		static ISzAlloc* getISzAlloc();

		/**
		 * @brief Retrieves a text for the error specified
		 */
		static std::string getErrorString( SRes error );

		/**
		 * @brief Conversing utf16 string to utf8 string
		 * @returns Return false if destination buffer is short
		 */
		static bool Utf16ToUtf8( unsigned char* dest, size_t* destLen, const short* src, size_t srcLen );

		/**
		 * @brief Conversing utf16 string to utf8 string
		 */
		static String Utf16ToUtf8( const short* src, size_t srcLen );

		/**
		 * @brief Conversing utf16 string to utf8 string
		 */
		static void Utf16ToUtf8( String& dest, const short* src, size_t srcLen );
	};

} // end of namespace Ogre

#endif // include guard, end of #ifndef __Ogre7zCommon_H__
